﻿using System.Data.Services;
using System.Linq;
using BookStoreService.Core.Models;
using BookStoreService.Core.Tools;

namespace BookStoreService.Core
{
    public class UsersDataServiceCore : DataService<UserList>
    {
        protected override UserList CreateDataSource()
        {
            var repository = RepositoryBuilder.Create<User>("Users.xml");
            if (repository.Query().ToList().Count == 0)
            {
                repository.Add(new User("Aviad"));
            }

            return new UserList(repository);
        }
    }
}
